package thread;

/**
 * 静态方法
 */
public class SyncDemo2 {
    public static void main(String[] args) {
        /*
        Thread t1 = new Thread(new Runnable() {
            public void run() {
                Boo.doSome();
            }
        });
         */
        /*
        Thread t1 = new Thread(()->{
                Boo.doSome();
        });
         */

        //方法引用
        Thread t1 = new Thread(Boo::doSome);
        Thread t2 = new Thread(Boo::doSome);
        t1.start();
        t2.start();
    }
}

class Boo{
    public static void doSome(){
        synchronized (Boo.class){
            try {
                Thread t = Thread.currentThread();
                System.out.println(t.getName()+"正在执行dosome方法");
                Thread.sleep(3000);
                System.out.println(t.getName()+"执行dosome方法完毕");
            } catch (InterruptedException e) {
            }
        }
    }
}
